#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lson rt<<1,s,mid
#define rson rt<<1|1,mid+1,e
using namespace std;
const int maxn = 1e6;
long long  tree[maxn<<2];
long long  lazy[maxn<<2];
long long a[maxn];
void pushup(long long rt)
{
	tree[rt] = tree[rt<<1]+tree[rt<<1|1];
}
void pushd(long long rt,long long  l,long long r)
{
	long long mid = (l+r)>>1;
	lazy[rt<<1] += lazy[rt];
	lazy[rt<<1|1] += lazy[rt];
	tree[rt<<1] += (mid-l+1)*lazy[rt];
	tree[rt<<1|1] += (r-mid)*lazy[rt];
	lazy[rt] = 0;
	
}
void build(long long rt,long long  s,long long  e)
{
	if(s==e)
	{
		tree[rt]=a[s];
		return ;
	}
	int mid =(s+e)>>1;
	build(lson);
	build(rson);
	pushup(rt);
}
void update(long long  rt,long long  s,long long  e,long long  l,long long  r,long long  val)
{
	if(l<=s&&e<=r)
	{
		tree[rt] += (e-s+1)*val;
		lazy[rt] += val;
		return ; 
	}
	if(lazy[rt]) pushd(rt,s,e);
	int mid = (s+e)>>1;
	if(l<=mid) update(lson,l,r,val);
	if(r>mid) update(rson,l,r,val);
	pushup(rt);
}
long long  query(long long  rt,long long  s,long long  e,long long  l,long long  r)
{
	if(l<=s&&e<=r)
	{
		return tree[rt];
	}
	if(lazy[rt]) pushd(rt,s,e);
	long long mid = (s+e)>>1;
	long long  sum = 0;
	if(l<=mid) sum += query(lson,l,r);
	if(r>mid) sum += query(rson,l,r);
	return sum;
}
int main()
{
	long long  n,m;
	while(scanf("%lld %lld",&n,&m)!=EOF)
	{
		memset(lazy,0,sizeof(lazy));
		memset(tree,0,sizeof(tree));
		for(int i = 1;i<=n;i++)scanf("%lld",&a[i]);
		build(1,1,n);
		while(m--)
		{
			char op;
			long long  l,r;
			scanf(" %c %lld %lld",&op,&l,&r);
		///	printf("****\n");
		//	printf("****%d %c\n",m,op);
			if(op=='Q')
			{
				printf("%lld\n",query(1,1,n,l,r));
			}
			else if(op=='C')
			{
				long long  val;
				scanf("%lld",&val);
				update(1,1,n,l,r,val);
			}
		}
	}
}
